//对称之美
import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt();
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.next();
            }
            int len = arr.length;
            int i = 0, j = len-1;
            for (; i < j; i++, j--) {
                if (!fun(arr[i].toCharArray(), arr[j].toCharArray())) {
                    System.out.println("No");
                    break;
                }
            }
            if (i >= j) {
                System.out.println("Yes");
            }
        }
    }
    public static boolean fun(char[] arr1, char[] arr2) {
        Set<Character> set = new HashSet<>();
        for (int i = 0; i < arr1.length; i++) {
            set.add(arr1[i]);
        }
        for (int i = 0; i < arr2.length; i++) {
            if (set.contains(arr2[i])) {
                return true;
            }
        }
        return false;
    }
}
//OR26
import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param A string字符串
     * @return int整型
     */
    public int getLongestPalindrome (String A) {
// write code here
        char[] arr = A.toCharArray();
        int max = 1;
        for (int i = 0; i < arr.length;i++) {
            max = Math.max(fun1(arr, i-1, i+1), Math.max(fun1(arr, i, i+1), max));
        }
        return max;
    }
    public int fun1(char[] arr, int l, int r) {
        int max = 0;
        while (l >= 0 && r < arr.length) {
            if (arr[l] == arr[r]) {
                l--;
                r++;
            } else {
                max = r-l-1;
                return max;
            }
        }
        max = r-l-1;
        return max;
    }

}
import java.util.*;
/**
public class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;

    public TreeNode(int val) {
        this.val = val;

    }

}
*/
public class Solution {
    public TreeNode Convert(TreeNode pRootOfTree) {
        TreeNode head = null;
        Stack<TreeNode> stack = new Stack<>();
        TreeNode previous = null;
        TreeNode tmp = pRootOfTree;
        while (!stack.isEmpty() || tmp != null) {
            while (tmp != null) {
                stack.push(tmp);
                tmp = tmp.left;
            }
            if (head == null) {
                head = stack.peek();
            }
            tmp = stack.pop();
            tmp.left = previous;
            if (previous != null){
                previous.right = tmp;
            }
            previous = tmp;
            
            tmp = tmp.right;
            
            
        }

        return head;
    }

}














